package o2o.config.jms.producer;

import com.jinyouapp.common.tools.jms.model.JMSNotify;
import o2o.config.jms.convert.NotifyMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

@Component
public class QueueMessageProducer {

    @Autowired
    private JmsTemplate jmsTemplate;
    @Autowired
    private NotifyMessageConverter messageConverter;
    @Autowired
    private Destination notifyQueue;

    public void sendQueue(JMSNotify notify) {
        sendMessage(notify);
    }

    private void sendMessage(JMSNotify notify) {
        // TODO Auto-generated method stub
        jmsTemplate.setMessageConverter(messageConverter);
        jmsTemplate.setPubSubDomain(false);
        jmsTemplate.convertAndSend(notifyQueue, notify);
    }
}
